<?php /* narato/vivasky */

//error_reporting(E_ALL & ~E_NOTICE);

define('WP_VERSION', $wp_version);
$narato_theme_data = get_theme_data(TEMPLATEPATH.'/style.css');
define('THEME_NAME', $narato_theme_data['Name']);
define('THEME_AUTHOR', $narato_theme_data['Author']);
define('THEME_URI', $narato_theme_data['URI']);
define('THEME_VERSION', trim($narato_theme_data['Version']));
define('THEME_URL', get_bloginfo('template_url'));

// end of line character
if(!defined("PHP_EOL")) define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");

if (class_exists('xili_language')):
define('THEME_TEXTDOMAIN','narato');
define('THEME_LANGS_FOLDER','/lang');
else:
load_theme_textdomain('narato', get_template_directory().'/lang');
endif;

// core files, required
require_once(TEMPLATEPATH.'/lib/core.php');
require_once(TEMPLATEPATH.'/lib/settings.php');

// optional, shortcodes
require_once(TEMPLATEPATH.'/lib/shortcodes.php');

// optional, extensions
require_once(TEMPLATEPATH.'/extensions/ip2country/ip2country.php');
require_once(TEMPLATEPATH.'/extensions/code-editing/code-editing.php');
require_once(TEMPLATEPATH.'/extensions/featured-posts/featured-posts.php');
require_once(TEMPLATEPATH.'/extensions/xtra-nav/xtra-nav.php');

require_once(TEMPLATEPATH.'/lib/widgets.php');
if(is_admin()) require_once(TEMPLATEPATH.'/admin/theme-settings.php');

if(current_user_can('edit_posts')):
require_once(TEMPLATEPATH.'/lib/editor.php');
add_filter('mce_css', 'narato_editor_styles');
add_filter('mce_buttons_2', 'narato_mcekit_editor_buttons');
add_filter('tiny_mce_before_init', 'narato_mcekit_editor_settings');
endif;

// search adjustments
add_filter('pre_get_posts','narato_exclude_pages_from_search');
//  add_filter('posts_where', 'narato_search_where');
//  add_filter('posts_join', 'narato_search_join');
//  add_filter('posts_groupby', 'narato_search_groupby');
add_action('narato_jquery_init', 'narato_highlight_search_query');

add_action('init', 'narato_verify_options');
add_action('init', 'narato_user_functions');
add_action('wp_head', 'narato_load_stylesheets', 1);
add_action('wp_head', 'narato_load_scripts', 1);
add_action('template_redirect', 'narato_meta_redirect');
//add_action('get_header', 'narato_compress_html');

add_filter('query_vars', 'narato_query_vars');
add_action('template_redirect', 'narato_dynamic_css_and_js');

add_filter('excerpt_more', 'narato_excerpt_more');

// set up widget areas
if (function_exists('register_sidebar')):
  register_sidebar(array(
	'name' => __('Default sidebar','narato'),
	'id' => 'sidebar-1',
	'description' => __("This is the default sidebar, visible on 2 or 3 column layouts. If no widgets are active, the default theme widgets will be displayed instead.","narato"),
	'before_widget' => '<section class="widget wdg-%2$s clearfix" id="wdg-%1$s">',
	'after_widget' => '</section>',
	'before_title' => '<h3 class="wdg-hd"><span>',
	'after_title' => '</span></h3>'
  ));

  register_sidebar(array(
	'name' => __('Secondary sidebar','narato'),
	'id' => 'sidebar-2',
	'description' => __("This sidebar is active only on a 3 column setup. ","narato"),
	'before_widget' => '<section class="widget wdg-%2$s clearfix" id="wdg-%1$s">',
	'after_widget' => '</section>',
	'before_title' => '<h3 class="wdg-hd"><span>',
	'after_title' => '</span></h3>'
  ));

  register_sidebar(array(
	'name' => __('Footer','narato'),
	'id' => 'footer-1',
	'description' => __("You can add between 1 and 6 widgets here (3 or 4 are optimal). They will adjust their size based on the widget count. ","narato"),
	'before_widget' => '<section class="widget widget-ft wdg-%2$s clearfix" id="wdg-%1$s">',
	'after_widget' => '</section>',
	'before_title' => '<h3 class="wdg-hd">',
	'after_title' => '</h3>'
  ));

  register_sidebar(array(
	'name' => __('Footer (slide 2)','narato'),
	'id' => 'footer-2',
	'description' => __("Only visible if jQuery is enabled. ","narato"),
	'before_widget' => '<section class="widget widget-ft wdg-%2$s clearfix" id="wdg-%1$s">',
	'after_widget' => '</section>',
	'before_title' => '<h3 class="wdg-hd">',
	'after_title' => '</h3>'
  ));

  register_sidebar(array(
	'name' => __('Footer (slide 3)','narato'),
	'id' => 'footer-3',
	'description' => __("Only visible if jQuery is enabled. ","narato"),
	'before_widget' => '<section class="widget widget-ft wdg-%2$s clearfix" id="wdg-%1$s">',
	'after_widget' => '</section>',
	'before_title' => '<h3 class="wdg-hd">',
	'after_title' => '</h3>'
  ));

  register_sidebar(array(
	'name' => __('Footer (slide 4)','narato'),
	'id' => 'footer-4',
	'description' => __("Only visible if jQuery is enabled. ","narato"),
	'before_widget' => '<section class="widget widget-ft wdg-%2$s clearfix" id="wdg-%1$s">',
	'after_widget' => '</section>',
	'before_title' => '<h3 class="wdg-hd">',
	'after_title' => '</h3>'
  ));
endif;

// set up post thumnails
add_theme_support('post-thumbnails');
$size = explode('x',get_narato_option('post_thumb'));
set_post_thumbnail_size($size[0],$size[1], true);
add_image_size('featured-thumbnail', 150, 150);

// nav menus
if(function_exists('register_nav_menus')) register_nav_menus(array('primary' => __('Primary Navigation', 'narato')));

add_theme_support('automatic-feed-links');
?>